﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FactoryMethod
{
    class Program
    {
        static void Main(string[] args)
        {
            Creator c1 = new BulbCreator();
            Creator c2 = new TubeCreator();

            Light l1 = c1.factory();
            Light l2 = c2.factory();

            l1.TurnOn();
            l1.TurnOff();

            Console.WriteLine("-----------------");

            l2.TurnOn();
            l2.TurnOff();

            Console.ReadKey();
        }
    }


    public abstract class Light
    {
        public abstract void TurnOn();
        public abstract void TurnOff();
    }

    public class BulbLight : Light
    {
        public override void TurnOn()
        {
            Console.WriteLine("Bulb Light is Turned on");
        }

        public override void TurnOff()
        {
            Console.WriteLine("Bulb Light is Turned off");
        }
    }

    public class TubeLight : Light
    {
        public override void TurnOn()
        {
            Console.WriteLine("Tube Light is Turned on");
        }

        public override void TurnOff()
        {
            Console.WriteLine("Tube Light is Turned off");
        }
    }

    public abstract class Creator
    {
        public abstract Light factory();
    }

    public class BulbCreator : Creator
    {
        public override Light factory()
        {
            return new BulbLight();
        }
    }

    public class TubeCreator : Creator
    {
        public override Light factory()
        {
            return new TubeLight();
        }
    }
}
